package com.wondertek.applet.controller.business;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wondertek.common.base.Result;
import com.wondertek.service.dto.app.req.AppDerReq;
import com.wondertek.service.dto.app.res.DeviceErrorRecordKvRes;
import com.wondertek.service.entity.business.DeviceErrorRecordPo;
import com.wondertek.service.service.business.DeviceErrorRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author wangyu
 */
@RestController
@RequestMapping("/app/error/record/")
@Tag(name = "app报警")
public class DeviceErrorRecordController {

    @Autowired
    private DeviceErrorRecordService deviceErrorRecordService;

    /**
     * app查询报警
     * @param appDerReq
     * @return
     */
    @PostMapping("/findList")
    @Operation(summary = "app查询报警")
    public Result<Page<DeviceErrorRecordKvRes>> findRecordList(@RequestBody AppDerReq appDerReq){
        return Result.success(deviceErrorRecordService.findRecordList(appDerReq));
    }

    /**
     * 根据id查询报警详情
     * @param id
     * @return
     */
    @PostMapping("/findById")
    @Operation(summary = "根据id查询报警详情")
    public Result<DeviceErrorRecordPo> findRecordDetailsById(@RequestParam("id") String id){
        return Result.success(deviceErrorRecordService.findRecordDetailsById(id));
    }


    /**
     * 根据id修改报警处理结果
     * @param req
     */
//    @PostMapping("/updateById")
//    @Operation(summary = "根据id修改报警处理结果")
//    public Result updateById(@RequestBody AppDerUpdReq req){
//        deviceErrorRecordService.updateById(req);
//        return Result.success();
//    }

    /**
     * 根据id修改已读状态
     * @param id
     */
    @GetMapping("/updateReadById")
    @Operation(summary = "根据id修改已读状态")
    public Result updateReadById(@RequestParam("id") String id){
        deviceErrorRecordService.updateAppReadById(id);
        return Result.success();
    }


}
